package com.corpdata.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.corpdata.common.result.Result;
import com.corpdata.service.LoginService;

@Controller
public class LoginController {
	
	@Autowired
	private LoginService loginService;
	
	@GetMapping("login")
	public String login(){
		return "login";
	}
	
	@ResponseBody
	@PostMapping("doLogin")
	public Result doLogin(String userId,String pwd,HttpServletRequest request){
		return loginService.doLogin(userId, pwd, request);
	}
	
	
	@GetMapping("logout")
	public String logout(HttpServletRequest request){
		loginService.logout(request);
		return "login";
	}
}
